package com.l.web.master.index;

import org.l.qiao.Cluster;
import org.l.qiao.LConstant;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.servlet.ModelAndView;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.util.List;

@Controller
@RequestMapping(LConstant.MASTER_URI)
public class IndexController {

    @Autowired
    private IndexService indexService;

    @RequestMapping("/index")
    //@Privilege(module = "公共",function = "首页" ,operation = "查看")
    public ModelAndView index(HttpServletRequest request, HttpServletResponse response, ModelMap modelMap) {
        indexService.index(modelMap);
        modelMap.put("a",request.getRequestURI());
        return new ModelAndView(LConstant.MASTER_URI + "/index");
    }

    @RequestMapping("childrenMenu")
    public ModelAndView childrenMenu(HttpServletRequest request, HttpServletResponse response, ModelMap modelMap) {
        String parentId = request.getParameter("parentid");
        List<Cluster> menus = indexService.getChildrenMenu(parentId);
        modelMap.put("menu1", menus);
        return new ModelAndView(LConstant.MASTER_URI + "/childrenMenu");
    }
}
